{% extends "base.html" %}
{% load staticfiles %}

{% block title %}实盘策略{% endblock %}

{% block content %}
    {#实盘列表删除#}
    <div class="modal fade" data-backdrop="static" id="modal_delete_paper">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">删除实盘策略确认</h4>
                </div>
                <div class="modal-body">
                    <div style="margin-top:3px;display: block" id="confirm_delete">
                        确认删除该实盘策略？
                    </div>
                    <div style="height: 30px; display: block;margin-top: 20px">
                        <div style="padding-left:120px; float: left;">
                                <span id="del_paper" sid_paper="" onclick="fad_delete_paper()"
                                      qb_num="" class="btn-cancel btn-stc">取消</span>
                        </div>
                        <div style="padding-left:5px; float: left;">
                            <span onclick="del_paper()" class="btn-confirm btn-stc">确定</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {# 打包失败模态框 #}
    <div class="modal fade" data-backdrop="static" id="modal_packageError"></div>
    {#打包的模态框#}
    <div class="modal fade" data-backdrop="static" id="modal_pack">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">打包确认</h4>
                </div>
                <div class="modal-body">
                    <div style="margin-top:3%; display: block">
                        确认打包策略?
                    </div>
                    <div style="height: 30px; display: block;margin-top: 20px">
                        <div style="padding-left:120px; float: left;">
                            <span id="attr_packid" packid="" onclick="fad_pack()" class="btn-cancel btn-stc">取消</span>
                        </div>
                        <div style="padding-left:5px; float: left;">
                            <span onclick="stg_pack()" class="btn-confirm btn-stc">确定</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {#操作成功模态框#}
    <div class="modal fade" data-backdrop="static" id="pack_success">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="success-title">打包</h4>
                </div>
                <div class="modal-body">
                    <div class="operat-success" id="msg_pack">
                        手工打包完成
                    </div>
                </div>
            </div>
        </div>
    </div>
    {#修改qb账号模态框#}
    <div class="modal fade" id="alterdb" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="dbnum-title">修改QB账号</h4>
                </div>
                <div class="modal-body">
                    <div style="margin-top:3%;display: none">
                        <input id="ruleid">
                    </div>
                    <div style="margin-top:3%">
                        <label class="qb-label">QB账号</label>
                        <input class="opts" id="qbmsg" type="text">
                        <span id="qbmsg_spaninfo" class="input-validation"></span>
                    </div>
                    <div style="height: 30px; display: block;margin-top: 20px">
                        <div style="padding-left:120px; float: left;">
                            <span class="btn-cancel btn-stc" onclick="fad_pack()">取消</span>
                        </div>
                        <div style="padding-left:5px; float: left;">
                            <span id="subqb" sid="" class="btn-confirm btn-stc" onclick="check_qb()">确定</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--业绩分析模态框-->
    <div class="modal fade" data-backdrop="static" id="modal_backtest_detail">
        <div class="modal-dialog" style="width: 1200px;height:600px">
            <div class="modal-content" style="background-color: #f5f5f5">
                <div class="modal-header" style="padding: 3px">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body" style="padding: 5px 30px 0px 30px;height:auto;">
                    {# 指标信息#}
                    <div class="row L1">
                        <div class="col-md-12">
                            <div class="box box-primary">
                                <div class="box-header with-border">
                                    <h3 class="box-title">收益概览</h3>
                                    <div>
                                        <p></p>
                                        <table class="display table table-striped tablelist">
                                            <tbody>
                                            <tr style="background-color: #dddddd">
                                                <th data-align="center">起始日期</th>
                                                <th data-align="center">结束日期</th>
                                                <th data-align="center">回测收益</th>
                                                <th data-align="center">回测年化收益</th>
                                                <th data-align="center">夏普率</th>
                                                <th data-align="center">索提诺比率</th>
                                                <th data-align="center">calmar比率</th>
                                                <th data-align="center">年化波动率</th>
                                                <th data-align="center">最大回撤</th>
                                            </tr>
                                            <tr class="even">
                                                <td data-align="center" id="start_date"></td>
                                                <td data-align="center" id="end_date"></td>
                                                <td data-align="center" id="total_return"></td>
                                                <td data-align="center" id="annual_return"></td>
                                                <td data-align="center" id="sharpe_ratio"></td>
                                                <td data-align="center" id="sortino_ratio"></td>
                                                <td data-align="center" id="calmar_ratio"></td>
                                                <td data-align="center" id="annual_volatility"></td>
                                                <td data-align="center" id="max_draw_down"></td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="box-header with-border">
                                    <h3 class="box-title">净值曲线</h3>
                                </div>
                                <div class="box-body " style="padding: 10px; height:350px;">
                                    <div id="cumulativereturns" style="height: 230px; width: 100%;">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- Main content -->
    <body>
    <section>
        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li class="active" style="margin-top:10px"><a href="#fa-pack" onclick="tabs(1)"
                                                              data-toggle="tab">打包列表</a></li>
                <li style="margin-top:10px"><a href="#fa-live" onclick="tabs(2)" data-toggle="tab">实盘列表</a></li>
            </ul>
            <div class="tab-content">
                <!--打包列表-->
                <div class="tab-pane active" id="fa-pack">
                    <div class="div-query">
                        <div class="lbl-query"><span>策略名称</span>
                            <input class="input-query" type="text" id="pstgname">
                        </div>
                        <div class="lbl-query"><span>打包状态 </span>
                            <select id="ppackstatus" class="input-query">
                                <option value=""></option>
                                <option value="0">待打包</option>
                                <option value="1">打包成功</option>
                                <option value="2">打包失败</option>
                            </select>
                        </div>
                        <div class="lbl-query">
                            <button class="btn-query" onclick="livePack_search()">查询
                            </button>
                        </div>
                    </div>
                    <table class="table-stc" id="packTable"></table>
                </div>
                <!--实盘列表-->
                <div class="tab-pane" id="fa-live">
                    <div class="div-query">
                        <div class="lbl-query"><span>策略ID </span>
                            <input class="input-query" type="text" id="sstgid">
                        </div>
                        <div class="lbl-query"><span>策略名称 </span>
                            <input class="input-query" type="text" id="sstgname">
                        </div>
                        <div class="lbl-query"><span>策略状态 </span>
                            <select id="lrunstatus" class="input-query">
                                <option value=""></option>
                                <option value="1">启动</option>
                                <option value="4">停止</option>
                            </select></div>
                        <div class="lbl-query">
                            <button class="btn-query" onclick="live_search()">查询
                            </button>
                        </div>
                    </div>
                    <table class="table-stc" id="liveTable">
                    </table>
                </div>
            </div>
        </div>
    </section>
    </body>
{% endblock %}

{% block scripts %}


    <script type="text/javascript">

        $(function () {
            livePack_search()
        })


        function tabs(n) {
            if (n == 1) {
                livePack_search();
                $('#fa-pack').addClass('active');
                $('#fa-live').removeClass('active');
            } else {
                live_search();
                $('#fa-pack').removeClass('active');
            }
        }

        //打包失败逻辑
        function stg_pack_error(d) {
            loadon()
            $('#modal_packageError').html("")
            $.post("{% url 'trade:live' %}", {'id': d, 'stg_pack_error': 1}, function (r) {
                loadoff()
                if (r.packmsg.length === 0) {
                    //window.location.reload();
                    //alert('无失败原因');
                } else {
                    var packError = '<div class="modal-dialog">\n' +
                        '            <div class="modal-content">\n' +
                        '                <div class="modal-header">\n' +
                        '                    <h4 class="modal-title">打包失败提示</h4>\n' +
                        '                </div>\n' +
                        '                <div class="modal-body">\n' +
                        '                   <div id="packError_spaninfo" style="margin-top:3%; display: block">\n' +
                        '                   </div>\n' +
                        '                <div style="height: 30px; display: block;margin-top: 20px">\n' +
                        '                   <div style="padding-left:120px; float: left;">\n' +
                        '                       <span id="packError_spaninfo" class="btn-confirm btn-stc" onclick="packErroBtnSub()">确定</span>\n' +
                        '                   </div>\n' +
                        '                </div>  \n' +
                        '           </div>' +
                        '       </div>' +
                        '</div>'


                    $('#modal_packageError').append(packError)
                    $('#modal_packageError').modal('show')
                    $('#packError_spaninfo').text(r.packmsg);
                }
            });
        };

        //打包失败信息确认按钮
        function packErroBtnSub() {
            $('#modal_packageError').modal('hide');
        }

        //打包模态框展示
        function stg_pack_show(d) {
            $('#modal_pack').modal('show');
            $('#attr_packid').attr('packid', d);
        }

        //打包逻辑
        function stg_pack() {
            d = $('#attr_packid').attr('packid');
            fad_pack()
            loadon()
            $.post("{% url 'trade:live' %}", {'id': d, 'stg_pack': 1}, function (r) {
                loadoff()
                if (r) {
                    $("#msg_pack").text("手工打包完成")
                    $("#packTable").bootstrapTable("destroy").bootstrapTable({
                        height: 600,
                        columns: [
                            {
                                field: 'stgid',
                                title: '策略ID',
                            }, {
                                field: 'stgname',
                                title: '策略名称',
                            }, {
                                field: 'packstatus',
                                title: '打包状态',
                            }, {
                                field: 'packtime',
                                title: '最后打包时间'
                            }, {
                                field: 'envname',
                                title: '运行环境'

                            }, {
                                field: 'poption',
                                title: '操作',
                                formatter: function (value, row, index) {
                                    if (row.packstatus == "打包失败" && row.isopr === "1") {
                                        return "<span onclick=\"stg_pack_show('" + value + "')\" type='button' class='btn btn-success btn-xs btn-flat btn_operation'> <i class='fa fa-file-zip-o'></i>打包</span> " +
                                            "&nbsp;<span id='pack_error_btn_disable' onclick=\"stg_pack_error('" + value + "')\" class='btn btn-danger btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-pencil'></i>失败原因</span> ";
                                    } else {
                                        return ''
                                    }

                                }
                            },
                        ],
                        data: r,
                        // height: 500,
                        {#width: 100,#}
                        //******前端分页设置****
                        pagination: true,
                        pageNumber: 1,
                        pageSize: 20,
                        pageList: [10, 20, 50, 200],
                        paginationHAlign: "right",
                        paginationDetailHAlign: "left"
                        //******前端分页设置****
                    });
                } else {
                    $("#msg_pack").text("服务器错误！")
                }
                $("#pack_success").modal("show");
                setTimeout(function () {
                    $("#pack_success").modal("hide");
                }, 2000)
            });
        };

        //打包模态框取消modal_pack
        function fad_pack() {
            $('#modal_pack').modal('hide');
            $("#alterdb").modal('hide');
        }

        //实盘列表删除的模态框
        function _delete_paper(d, stgname, qbnum) {
            $('#modal_delete_paper').modal('show');
            $("#confirm_delete").text("确认删除" + "'" + stgname + "'" + "策略?");
            $('#del_paper').attr('sid_paper', d);
            $('#del_paper').attr('qb_num', qbnum);
        }

        //实盘列表删除取消
        function fad_delete_paper() {
            $('#modal_delete_paper').modal('hide');
        }

        //实盘列表删除逻辑
        function del_paper() {
            d = $('#del_paper').attr('sid_paper');
            qb = $('#del_paper').attr('qb_num');
            //点击后取消模态框，出现加载中页面
            fad_delete_paper()
            loadon()
            $.post("{% url 'trade:live' %}", {'id': d, 'delete_live_list': 1, 'qbnum': qb}, function (r) {
                loadoff()
                $("#success-title").text("删除")
                if (r) {
                    $("#liveTable").bootstrapTable("destroy").bootstrapTable({
                        height: 600,
                        columns: [
                            {
                                field: 'stgid',
                                title: '策略ID'
                            }, {
                                field: 'stgname',
                                title: '策略名称'
                            }, {
                                field: 'audittime',
                                title: '申请实盘时间',
                            }, {
                                field: 'runstatus',
                                title: '运行状态'
                            }, {
                                title: '开始运行时间',
                                field: 'starttime'
                            }, {
                                title: '结束运行时间',
                                field: 'endtime'
                            }, {
                                title: 'QB账号',
                                field: 'remark'
                            }, {
                                field: 'loption',
                                title: '操作',
                                halign: 'center',
                                align: 'right',
                                formatter: function (value, row, index) {
                                    var stop = '';
                                    var edit = "";
                                    var stgname = row.stgname;
                                    var analy = "";
                                    //业绩分析按钮
                                    if (row.stggroup !== "3") {
                                        analy = "<span  class='btn btn-analysis btn-xs btn-flat btn_operation'  onclick=\"analysis('" + value + "')\"> <i class='fa fa-pencil'></i>业绩分析</span> ";
                                    }
                                    if (row.runstatus == '停止' && row.isopr === "1") {
                                        stop = "<span onclick=\"_delete_paper('" + value + "','" + stgname + "','" + row.remark + "')\" class='btn btn-danger btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-trash'></i>删除</span> "
                                    }
                                    if (row.runstatus == '停止' && !row.stgid.toString().startsWith("5")) {
                                        edit = "<span onclick=\"alter_qb('" + value + "','" + row.remark + "')\" class='btn btn-primary btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-pencil'></i>编辑</span> "
                                    }
                                    return stop + edit + analy;
                                }
                            },
                        ],
                        data: r,
                        // height: 600,
                        {#width: 100,#}
                        //******前端分页设置****
                        pagination: true,
                        pageNumber: 1,
                        pageSize: 20,
                        pageList: [10, 20, 50, 200],
                        paginationHAlign: "right",
                        paginationDetailHAlign: "left"
                        //******前端分页设置****
                    });
                    $("#msg_pack").text("删除成功！");
                } else {
                    $("#msg_pack").text("服务器错误！");
                }
                $("#pack_success").modal("show");
                setTimeout(function () {
                    $("#pack_success").modal("hide");
                }, 2000)
            });//post请求的回调函数，空值show"默认合约不可修改"，y值则删除后跳转。
        };

        // 打包查询
        function livePack_search() {
            var pstgname = $("#pstgname").val();
            var ppackstatus = $("#ppackstatus").val();
            // 整理发送后台的数据
            var data = {
                "pstgname": pstgname,
                "ppackstatus": ppackstatus,
            };

            var JsonData = JSON.stringify(data);
            $.post("{% url 'trade:live_approval' %}", {"data": JsonData, 'livePack_search': 1}, function (r) {
                $("#packTable").bootstrapTable("destroy").bootstrapTable({
                    height: 600,
                    columns: [
                        {
                            field: 'stgid',
                            title: '策略ID',
                        }, {
                            field: 'stgname',
                            title: '策略名称',
                        }, {
                            field: 'packstatus',
                            title: '打包状态',
                        }, {
                            field: 'packtime',
                            title: '最后打包时间'
                        }, {
                            field: 'backtype',
                            title: "主/备"
                        }, {
                            field: 'envname',
                            title: '运行环境'

                        }, {
                            field: 'poption',
                            title: '操作',

                            formatter: function (value, row, index) {
                                if (row.packstatus == "打包失败" && row.isopr === "1") {
                                    return "<span onclick=\"stg_pack_show('" + value + "')\" type='button' class='btn btn-success btn-xs btn-flat btn_operation'> <i class='fa fa-pencil'></i>打包</span> " + "&nbsp;<span id='pack_error_btn_disable' onclick=\"stg_pack_error('" + value + "')\" class='btn btn-danger btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-pencil'></i>失败原因</span> ";
                                } else {
                                    return ''
                                }

                            }
                        },
                    ],
                    data: r,
                    // height: 500,
                    {#width: 100,#}
                    //******前端分页设置****
                    pagination: true,
                    pageNumber: 1,
                    pageSize: 20,
                    pageList: [10, 20, 50, 200],
                    paginationHAlign: "right",
                    paginationDetailHAlign: "left"
                    //******前端分页设置****
                });
            });

        }

        // 实盘查询
        function live_search() {

            var lstgid = $("#sstgid").val();
            var lstgname = $("#sstgname").val();
            var lrunstatus = $("#lrunstatus").val();
            // 整理发送后台的数据
            var data = {
                "lstgid": lstgid,
                "lstgname": lstgname,
                "lrunstatus": lrunstatus
            };

            var JsonData = JSON.stringify(data);
            $.post("{% url 'trade:live_approval' %}", {"data": JsonData, 'live_search': 1}, function (r) {
                $("#liveTable").bootstrapTable("destroy").bootstrapTable({
                    height: 600,
                    columns: [
                        {
                            field: 'stgid',
                            title: '策略ID'
                        }, {
                            field: 'stgname',
                            title: '策略名称'
                        }, {
                            field: 'audittime',
                            title: '申请实盘时间',
                        }, {
                            field: 'runstatus',
                            title: '运行状态'
                        }, {
                            title: '开始运行时间',
                            field: 'starttime'
                        }, {
                            title: '结束运行时间',
                            field: 'endtime'
                        }, {
                            title: 'QB账号',
                            field: 'remark'
                        }, {
                            field: 'loption',
                            title: '操作',
                            halign: 'center',
                            align: 'right',
                            formatter: function (value, row, index) {
                                var stop = '';
                                var edit = "";
                                var stgname = row.stgname;
                                var analy = "";
                                //业绩分析按钮
                                if (row.stggroup !== "3") {
                                    analy = "<span  class='btn btn-analysis btn-xs btn-flat btn_operation'  onclick=\"analysis('" + value + "')\"> <i class='fa fa-pencil'></i>业绩分析</span> ";
                                }
                                if (row.runstatus == '停止' && row.isopr === "1") {
                                    stop = "<span onclick=\"_delete_paper('" + value + "','" + stgname + "','" + row.remark +  "')\" class='btn btn-danger btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-trash'></i>删除</span> "
                                }
                                if (row.runstatus == '停止' && !row.stgid.toString().startsWith("5")) {
                                    edit = "<span onclick=\"alter_qb('" + value + "','" + row.remark + "')\" class='btn btn-primary btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-pencil'></i>编辑</span> "
                                }
                                return stop + edit + analy;
                            }
                        },
                    ],
                    data: r,
                    // height: 600,
                    {#width: 100,#}
                    //******前端分页设置****
                    pagination: true,
                    pageNumber: 1,
                    pageSize: 20,
                    pageList: [10, 20, 50, 200],
                    paginationHAlign: "right",
                    paginationDetailHAlign: "left"
                    //******前端分页设置****
                });
            });

        }

        // 修改qb账号模态框
        function alter_qb(stgid, remark) {
            $("#qbmsg_spaninfo").text("")
            $("#ruleid").val(stgid)
            $("#qbmsg").val(remark)
            $("#alterdb").modal('show')
        }

        //校验qb账号 （不需要传策略id）
        function check_qb() {
            var qbnum = $("#qbmsg").val()
            if (qbnum.length === 0) {
                $("#qbmsg_spaninfo").text("QB账号为必填项！")
                return;
            }
            $.ajax({
                type: "post",
                url: "/trade/check_qb/",
                data:
                    {
                        "qbnum": qbnum,
                    },
                success: function (data) {
                    $("#qbmsg_spaninfo").text(data)
                    if (!data) {
                        sub_qb()
                    }
                }
            })
        }

        // 提交qb账号
        function sub_qb() {
            fad_pack()
            loadon()
            var ruleid = $("#ruleid").val()
            var qbmsg = $("#qbmsg").val()
            $.ajax({
                type: "post",
                url: "/trade/alter_qb/",
                data:
                    {
                        "stgid": ruleid,
                        "qbnum": qbmsg,
                    },
                success: function (data) {
                    $("#success-title").text("修改QB账号")
                    if (data === "no") {
                        $("#msg_pack").text("当前qb账号已存在，请重新输入！")
                    } else if (data) {
                        $("#liveTable").bootstrapTable("destroy").bootstrapTable({
                            height: 600,
                            columns: [
                                {
                                    field: 'stgid',
                                    title: '策略ID'
                                }, {
                                    field: 'stgname',
                                    title: '策略名称'
                                }, {
                                    field: 'audittime',
                                    title: '申请实盘时间',
                                }, {
                                    field: 'runstatus',
                                    title: '运行状态'
                                }, {
                                    title: '开始运行时间',
                                    field: 'starttime'
                                }, {
                                    title: '结束运行时间',
                                    field: 'endtime'
                                }, {
                                    title: 'QB账号',
                                    field: 'remark'
                                }, {
                                    field: 'loption',
                                    title: '操作',
                                    halign: 'center',
                                    align: 'right',
                                    formatter: function (value, row, index) {
                                        var stop = '';
                                        var edit = "";
                                        var stgname = row.stgname;
                                        var analy = "";
                                        //业绩分析按钮
                                        if (row.stggroup !== "3") {
                                            analy = "<span  class='btn btn-analysis btn-xs btn-flat btn_operation'  onclick=\"analysis('" + value + "')\"> <i class='fa fa-pencil'></i>业绩分析</span> ";
                                        }
                                        if (row.runstatus == '停止' && row.isopr === "1") {
                                            stop = "<span onclick=\"_delete_paper('" + value + "','" + stgname + "','" + row.remark +  "')\" class='btn btn-danger btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-trash'></i>删除</span> "
                                        }
                                        if (row.runstatus == '停止' && !row.stgid.toString().startsWith("5")) {
                                            edit = "<span onclick=\"alter_qb('" + value + "','" + row.remark + "')\" class='btn btn-primary btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_model_field'> <i class='fa fa-pencil'></i>编辑</span> "
                                        }
                                        return stop + edit + analy;
                                    }
                                },
                            ],
                            data: data,
                            // height: 600,
                            {#width: 100,#}
                            //******前端分页设置****
                            pagination: true,
                            pageNumber: 1,
                            pageSize: 20,
                            pageList: [10, 20, 50, 200],
                            paginationHAlign: "right",
                            paginationDetailHAlign: "left"
                            //******前端分页设置****
                        });
                        $("#msg_pack").text("修改成功！")
                    } else {
                        $("#msg_pack").text("服务器报错！")
                    }
                    loadoff()
                    $("#pack_success").modal("show");
                    setTimeout(function () {
                        $("#pack_success").modal("hide");
                    }, 2000)
                }
            })

        }

        //业绩分析逻辑
        function analysis(stgid) {

            //收益概览获取值
            var td_ele = $("tr.even").children("td")
            td_ele.text("-")

            //遍历td，将后台获取的值根据元素的id进行渲染。
            $.get(" {% url 'trade:live_incomeStatistics' %}", {'stgid': stgid}, function (r) {
                if (r) {
                    for (const key in r) {
                        if ($('#' + key)) {
                            $('#' + key).text(r[key]);
                        }

                    }
                }
            });

            /**
             td_ele.each(function () {
                console.log($(this).attr("id"))
            })
             **/

            //净值曲线获取值 + 图像渲染
            $.get("{%url 'trade:live_cumulativereturns'%}", {'stgid': stgid}, function (result) {
                setTimeout(function () {
                    var myChart = echarts.init(document.getElementById('cumulativereturns'));
                    var option = {
                        tooltip: {
                            trigger: 'axis',
                            formatter: function (obj) {
                                return obj[0].seriesName + ":" + obj[0].value + '<br>';
                            }
                        },
                        grid: {
                            left: '5%',   // 与容器左侧的距离
                            right: '5%', // 与容器右侧的距离
                            top: '5%',   // 与容器顶部的距离
                            bottom: '22%', // 与容器底部的距离
                        },
                        dataZoom: [
                            {
                                show: true,
                                realtime: true,
                                start: 0,
                                end: 100
                            },
                            {
                                type: 'inside',
                                realtime: true,
                                start: 0,
                                end: 100
                            }
                        ],
                        xAxis: {
                            type: 'category',
                            data: null,
                            scale: true
                        },
                        yAxis: {
                            type: 'value',
                            scale: true
                        },
                        series: [{
                            name: '净值',
                            data: null,
                            type: 'line',
                        },
                        ]
                    };
                    option.series[0].data = result.retData;
                    option.xAxis.data = result.retDate;
                    myChart.setOption(option);
                }, 500)

            })


            $("#modal_backtest_detail").modal("show")


        }

    </script>
    <style>
        {#加载数据时的样式#}
        .bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading {
            align-items: center;
            background: #141414;
            display: none;
            justify-content: center;
            position: absolute;
            bottom: 0;
            width: 100%;
            z-index: 1000;
        }
    </style>

{% endblock %}